<template>
    <el-dialog
        class="withdraw-info-dialog"
        title="详情"
        v-model="dialogVisible"
        width="60%"
        @close="closedCallback"
        :align-center="true">
        <el-form :model="form" ref="formRef" label-width="auto">
            <h1>提现信息</h1>
            <el-form-item label="提现编号：">{{ form.sn || '-' }}</el-form-item>
            <el-form-item label="昵称："> {{ form.nickName || '-' }}</el-form-item>
            <el-form-item label="姓名："> {{ form.realName || '-' }}</el-form-item>
            <el-form-item label="手机号："> {{ form.mobile || '-' }}</el-form-item>
            <!-- todo:身份证号 -->
            <el-form-item label="身份证号：">{{ form.idNo || '-' }}</el-form-item>
            <el-form-item label="提现金额："> {{ form.amount ? `¥ ${form.amount / 100}` : '-' }}</el-form-item>
            <el-form-item label="提现至：">{{ form.withdrawToName || '-' }}</el-form-item>
            <el-form-item label="银行卡信息：">
                <template v-if="form.withdrawTo == 1"> - </template>
                <template v-else> {{ form.bankName }} ({{ form.bankAccountNo }}) </template>
            </el-form-item>
            <el-form-item label="申请时间：">{{ form.createdAt || '-' }}</el-form-item>
            <h1>审核信息</h1>
            <!-- withdrawTo 1 微信 -->
            <el-form-item label="审核状态：">
                {{ form.auditStatusName || '-'
                }}<template v-if="form.auditResult == 1 && form.auditStatus == 4"
                    >（错误原因：{{ form.failedReason }}）</template
                >
            </el-form-item>
            <template v-if="form.auditResult == 1">
                <el-form-item label="打款方式：">{{ form.transferTypeName || '-' }}</el-form-item>
                <el-form-item label="打款凭证：" v-if="form.transferType == 1">
                    <el-image
                        style="width: 80px; height: 80px"
                        :src="form.transferReceipt"
                        :fit="'fill'"
                        :preview-src-list="[form.transferReceipt]" />
                </el-form-item>
            </template>
            <el-form-item label="拒绝原因：" v-if="form.auditResult == 2">
                <div class="reject-reason">{{ form.rejectReason || '-' }}</div>
            </el-form-item>
            <el-form-item label="审核时间：">{{ form.auditAt || '-' }}</el-form-item>
        </el-form>
        <!-- <template #footer>
            <div style="flex: auto">
                <el-button plain @click="handleVisible(false)">关闭</el-button>
            </div>
        </template> -->
    </el-dialog>
</template>

<script setup>
import { reactive, ref } from 'vue';
import request from '@/request/index';
import { cloneDeep } from '@/commons/utils.js';

const formRef = ref();
let form = reactive({
    id: null,
    sn: '',
    nickName: '',
    realName: '',
    mobile: '',
    idNo: '',
    withdrawTo: null,
    withdrawToName: '',
    bankName: '',
    bankAccountNo: '',
    auditStatus: null,
    auditStatusName: '',
    failedReason: '',
    rejectReason: '',
    auditAt: '',
    createdAt: '',
    amount: '',
    auditResult: null,
    auditResultName: '',
    transferType: null, //打款方式：1-线下打款 2-微信 3-宝付账户
    transferTypeName: '',
    transferReceipt: ''
});
let dialogVisible = ref(false);
let formClone = cloneDeep(form);

const openDialog = async row => {
    const { data } = await request('withdrawInfo', { id: row.id });
    Object.assign(form, data);
    handleVisible(true);
};
const closedCallback = () => {
    Object.assign(form, cloneDeep(formClone));
    formRef.value.resetFields();
};
const handleVisible = (visible = false) => {
    dialogVisible.value = visible;
};
const handleConfirm = () => {
    handleVisible();
};

defineExpose({
    openDialog
});
</script>

<style lang="scss">
.withdraw-info-dialog {
    max-width: 700px;
    min-width: 700px;
    .el-dialog__body {
        padding-left: 34px !important;
        max-height: 600px;
        overflow-y: auto;
    }
    .el-form-item {
        margin-bottom: 8px;
    }
}
</style>
<style lang="scss" scoped>
.withdraw-info-dialog {
    h1 {
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #33302d;
        position: relative;
        margin: 0;
        padding: 0;
        margin-bottom: 17px;
        &:not(:first-of-type) {
            margin-top: 23px;
        }
        &::before {
            position: absolute;
            content: '';
            left: -10px;
            width: 4px;
            height: 16px;
            background: #ff6b00;
            top: 50%;
            transform: translateY(-50%);
        }
    }
    .reject-reason {
        line-height: 22px;
        width: 90%;
    }
}
</style>
